﻿#include "FITKAbaInteractionSurfToSurfStandard.h"


Interface::FITKAbaAbstractInteraction::FITKAbaInteractionType Interface::FITKAbaInteractionSurfToSurfStandard::getInteractionType() const
{
    return Interface::FITKAbaAbstractInteraction::FITKAbaInteractionType::SurfToSurfContactStandard;
}

bool Interface::FITKAbaInteractionSurfToSurfStandard::copy(FITKAbstractDataObject *obj)
{
    return true;
}

bool Interface::FITKAbaInteractionSurfToSurfStandard::isModifiedInStep(int stepId) const
{
    if (stepId <= 0 || stepId == m_createdStepId)
        return false;
    if (m_modifiedDatas.contains(stepId))
        return true;
    return false;
}

void Interface::FITKAbaInteractionSurfToSurfStandard::activeStateChanged()
{
    //清理数据状态
    if (m_deactiveStepId == -1)
        return;
    //访问当前算例的分析步管理器，获取分析步顺序id列表。
    QVector<int> stepIds = this->getStepIds();
    int index = stepIds.indexOf(m_deactiveStepId);
    if (index == -1)
        return;
    for (int i = index ; i < stepIds.count(); ++i)
    {
        int id = stepIds[i];
        if (m_modifiedDatas.contains(id))
            m_modifiedDatas.remove(id);
    }
}


namespace Interface {
    FITKAbaAbstractInteraction::SlidingFormulation FITKAbaInteractionSurfToSurfStandard::getSlidingFormulation() const
{
    return m_slidingFormulation;
}

void FITKAbaInteractionSurfToSurfStandard::setSlidingFormulation(SlidingFormulation newSlidingFormulation)
{
    m_slidingFormulation = newSlidingFormulation;
}

FITKAbaInteractionSurfToSurfStandard::FITKAbaInteractionSurfToSurfStandard::ContactDiscretizationMethod FITKAbaInteractionSurfToSurfStandard::getDiscretizationMethod() const
{
    return m_discretizationMethod;
}

void FITKAbaInteractionSurfToSurfStandard::setDiscretizationMethod(ContactDiscretizationMethod newDiscretizationMethod)
{
    m_discretizationMethod = newDiscretizationMethod;
}

bool FITKAbaInteractionSurfToSurfStandard::getExcludeShellMembranceElementThickness() const
{
    return m_excludeShellMembranceElementThickness;
}

void FITKAbaInteractionSurfToSurfStandard::setExcludeShellMembranceElementThickness(bool newExcludeShellMembranceElementThickness)
{
    m_excludeShellMembranceElementThickness = newExcludeShellMembranceElementThickness;
}

FITKAbaInteractionSurfToSurfStandard::ContactTracking FITKAbaInteractionSurfToSurfStandard::getContactTracking() const
{
    return m_contactTracking;
}

void FITKAbaInteractionSurfToSurfStandard::setContactTracking(ContactTracking newContactTracking)
{
    m_contactTracking = newContactTracking;
}

FITKAbaInteractionSurfToSurfStandard::SlaveAdjustment FITKAbaInteractionSurfToSurfStandard::getSlaveAdjustment() const
{
    return m_slaveAdjustment;
}

void FITKAbaInteractionSurfToSurfStandard::setSlaveAdjustment(SlaveAdjustment newSlaveAdjustment)
{
    m_slaveAdjustment = newSlaveAdjustment;
}

double FITKAbaInteractionSurfToSurfStandard::getAdjustTolerance() const
{
    return m_adjustTolerance;
}

void FITKAbaInteractionSurfToSurfStandard::setAdjustTolerance(double newAdjustTolerance)
{
    m_adjustTolerance = newAdjustTolerance;
}

int FITKAbaInteractionSurfToSurfStandard::getAdjustNodeSetId() const
{
    return m_adjustNodeSetId;
}

void FITKAbaInteractionSurfToSurfStandard::setAdjustNodeSetId(int newAdjustNodeSetId)
{
    m_adjustNodeSetId = newAdjustNodeSetId;
}

bool FITKAbaInteractionSurfToSurfStandard::getTieAdjustSurfaces() const
{
    return m_tieAdjustSurfaces;
}

void FITKAbaInteractionSurfToSurfStandard::setTieAdjustSurfaces(bool newTieAdjustSurfaces)
{
    m_tieAdjustSurfaces = newTieAdjustSurfaces;
}

FITKAbaInteractionSurfToSurfStandard::UseSupplementaryContactPairs FITKAbaInteractionSurfToSurfStandard::getUseSupplementaryContactPairs() const
{
    return m_useSupplementaryContactPairs;
}

void FITKAbaInteractionSurfToSurfStandard::setUseSupplementaryContactPairs(UseSupplementaryContactPairs newUseSupplementaryContactPairs)
{
    m_useSupplementaryContactPairs = newUseSupplementaryContactPairs;
}

FITKAbaInteractionSurfToSurfStandard::InitialClearance FITKAbaInteractionSurfToSurfStandard::getInitialClearance() const
{
    return m_initialClearance;
}

void FITKAbaInteractionSurfToSurfStandard::setInitialClearance(InitialClearance newInitialClearance)
{
    m_initialClearance = newInitialClearance;
}

double FITKAbaInteractionSurfToSurfStandard::getUniformClearance() const
{
    return m_uniformClearance;
}

void FITKAbaInteractionSurfToSurfStandard::setUniformClearance(double newUniformClearance)
{
    m_uniformClearance = newUniformClearance;
}

int FITKAbaInteractionSurfToSurfStandard::getInteractionPropertyId(int stepId)
{
    return m_InteractionPropertyId;
}

void FITKAbaInteractionSurfToSurfStandard::setInteractionPropertyId(int newInteractionPropertyId, int stepId)
{
    if (stepId <=0 || stepId == m_createdStepId)
        m_InteractionPropertyId = newInteractionPropertyId;
    else
    {
        if (!m_modifiedDatas.contains(stepId))
            m_modifiedDatas[stepId] = this->getInteractionPorpertyIdInStep(stepId);
        m_modifiedDatas[stepId] = newInteractionPropertyId;
    }
}

int FITKAbaInteractionSurfToSurfStandard::getInteractionPorpertyIdInStep(int stepId)
{
    if (stepId <= 0 || stepId == m_createdStepId)
        return m_InteractionPropertyId;
    if (m_modifiedDatas.contains(stepId))
        return m_modifiedDatas[stepId];
    QVector<int> stepIds = this->getStepIds();
    int createdStepIndex = stepIds.indexOf(m_createdStepId);
    int stepIndex = stepIds.indexOf(stepId);
    if (!(createdStepIndex >= 0 && createdStepIndex < stepIds.size()))
        return m_InteractionPropertyId;
    if (!(stepIndex >= 0 && stepIndex < stepIds.size()))
        return m_InteractionPropertyId;
    for (int i = stepIndex; i >= createdStepIndex; --i)
    {
        int id = stepIds.at(i);
        if (m_modifiedDatas.contains(id))
            return m_modifiedDatas[id];
    }
    return m_InteractionPropertyId;
}

}
